{% extends '/admin/admin.html' %}

{% block con %}

<div class="span9">
    <h1>
        用户列表
    </h1>
    <table class="table table-bordered table-striped">
        <thead>
            <tr>
                <th>用户编号</th>
                <th>用户名</th>
                <th>手机号</th>
                <th>发布博文数量 </th>
                <th>评论次数</th>
                <th>状态</th>
                <th>注册时间</th>
                <th>查看</th>
            </tr>
        </thead>
        <tbody>
            {% for v in users.items %}
            <tr>
                <td>{{ v.id }}</td>
                <td>{{ v.username }}</td>
                <td>{{ v.phone }}</td>
                <td>{{ v.posts|length }}</td>
                <td>{{ v.comments|length }}</td>
                <td>
                    <select name="status" uid="{{ v.id }}" style="width: 100px;">
                        <option value="0" {% if v.status == 0 %} selected  {% endif %}>正常</option>
                        <option value="1" {% if v.status == 1 %} selected  {% endif %}>禁用</option>
                    </select>
                </td>
                    
                <td>{{ v.addtime }}</td>
                <td>
                    <a href="{{ url_for('home.userblogs',uid=v.id)}}" class="view-link">查看ta的博客</a>
                </td>
            </tr>
            {% endfor %}
            
        </tbody>
    </table>                
    <div class="pagination">
        <ul>
            <li class="disabled">
                <a href="#">«</a>
            </li>
           

            {% for v in users.iter_pages() %}

            <li {% if v == request.args.get('p',1)|int %} class="active" {% endif %}>
                <a href="{% if v %} ?p={{ v }} {% else %} javascript:void(0) {% endif %}"  >{{ v|d('...',true) }}</a>
            </li>
            {% endfor %}
            
            <li>
                <a href="#">»</a>
            </li>
        </ul>
    </div>
    </div>



{% endblock %}

{% block js %}
<script type="text/javascript">
    $('select[name=status]').change(function(){
        var v = $(this).val()
        var uid = $(this).attr('uid')
        // 发送ajax
        $.get('{{ url_for("admin.useredit")}}',{'status':v,'uid':uid})
    })


</script>
{% endblock %}